package com.mybase.app.UI;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import com.mybase.app.UI.animation.AnimationActivity;
import com.mybase.app.UI.dialog.DialogActivity;
import com.mybase.app.UI.dialog.PopupWindowActivity;
import com.mybase.app.entity.MyMenuItem;
import com.mybase.app.UI.toolbar.SampleActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by happy_000 on 2014/12/5.
 *
 * 各种交互性 组件 第三方交互性组件
 */
public class UIHomeActivity extends ListActivity {

    private ListAdapter mAdapter;
    List<MyMenuItem> itemList=new ArrayList<MyMenuItem>(0);
    private List<String> list=new ArrayList<String>(0);


    public List<MyMenuItem> getRootMenuItems() {
        List<MyMenuItem> list=new ArrayList<MyMenuItem>(0);

        MyMenuItem menuItem1 = new MyMenuItem();
        menuItem1.setName("使用自定View的Activity");
        menuItem1.setActivity(MyViewActivity.class);
        list.add(menuItem1);
        //**********************************************************
        MyMenuItem menuItem01 = new MyMenuItem();
        menuItem01.setName("CusetemView 自定义View");
        menuItem01.setActivity(RotatActivity.class);
        list.add(menuItem01);
        //**********************************************************
        MyMenuItem menuItem02 = new MyMenuItem();
        menuItem02.setName("Widget 控件");
        menuItem02.setActivity(WidgetActivity.class);
        list.add(menuItem02);
        //###########################
        MyMenuItem menuItem2 = new MyMenuItem();
        menuItem2.setName("Bulletin  提示|布告");
        menuItem2.setActivity(BulletinActivity.class);
        list.add(menuItem2);
        //**********************************************************
        MyMenuItem menuItem3 = new MyMenuItem();
        menuItem3.setName("popupwindow  对话框");
        menuItem3.setActivity(PopupWindowActivity.class);
        list.add(menuItem3);
        //**********************************************************
        MyMenuItem menuItem4 = new MyMenuItem();
        menuItem4.setName("DiaLogs 对话框");
        menuItem4.setActivity(DialogActivity.class);
        list.add(menuItem4);

        //**********************************************************
        MyMenuItem menuItem5 = new MyMenuItem();
        menuItem5.setName("Animation");
        menuItem5.setActivity(AnimationActivity.class);
        list.add(menuItem5);
        //**********************************************************
        //**********************************************************
        MyMenuItem menuItem6 = new MyMenuItem();
        menuItem6.setName("ToolBar");
        menuItem6.setActivity(SampleActivity.class);
        list.add(menuItem6);
        //**********************************************************
        return list;
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        itemList= getRootMenuItems();
        initdatas();
        mAdapter=new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1,list);
        setListAdapter(mAdapter);
    }
    private  void initdatas(){
        for (MyMenuItem myMenuItem : itemList) {
            list.add(myMenuItem.getName());
        }
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        MyMenuItem myMenuItem=itemList.get(position);
        Intent intent=new Intent(UIHomeActivity.this,myMenuItem.getActivity());
        startActivityForResult(intent,RESULT_OK);
    }
}
